package middlewares

import (
	"godemo/common"
	"log"
	"net/http"

	"github.com/gin-gonic/gin"
)

func ValidLogin() gin.HandlerFunc {
	return func(c *gin.Context) {
		var uid = common.SessionUid()
		if uid == "" {
			log.Println("redirect login")
			c.Redirect(http.StatusMovedPermanently, "/login")
			return
		}
		c.Next()

	}
}
